#include <iostream>
using namespace std;

typedef long long ll;
const ll mod = 10e9 + 7;
ll ans = 1;
ll N;
ll ksm(ll a, ll b)
{
    ll sum = 1, base = a;
    while (b != 0)
    {
        if ((b & 1) != 0)
        {
            sum *= base;
        }
        base *= base;
        b >>= 1;
    }
    return sum;
}
int main()
{
    cin >> N;
    ll sum;
    for (int i = 1; i <= N; i++)
    {
        sum = ksm(i, N) % mod;
        ans = ans ^ sum;
    }
    cout << ans;
}